The goals / steps of this project are the following:
Here I will consider the rubric points individually and describe how I addressed each point in my implementation
| CRITERIA | MEETS SPECIFICATIONS | HOW I ADDRESSED THE POINT | |
|---|---|---|---|
| Submission Files | The project submission includes all required files. | Traffic_Sign_Classifier.ipynb notebook file is part of this repository. An HTML export of the project notebook with the name report.html is part of this repository. Any additional datasets or images used for the project that are not from the German Traffic Sign Dataset is part of this repository. Writeup report as a markdown file is part of this repository | |
| Dataset Summary | The submission includes a basic summary of the data set. | Please see section Data Set Summary & Exploration, and sub-sections 1. Provide a basic summary of the data set. In the code, the analysis should be done using python, numpy and/or pandas methods rather than hardcoding results manually, 2. Include an exploratory visualization of the dataset, 2.1 Frequency Distribution, 2.2 Checking for unbalanced classes, 2.3 Plot Signal Images | |
| Exploratory Visualization | The submission includes an exploratory visualization on the dataset. | Please see section Data Set Summary & Exploration, and sub-sections 1. Provide a basic summary of the data set. In the code, the analysis should be done using python, numpy and/or pandas methods rather than hardcoding results manually, 2. Include an exploratory visualization of the dataset, 2.1 Frequency Distribution, 2.2 Checking for unbalanced classes, 2.3 Plot Signal Images | |
| Preprocessing | The submission describes the preprocessing techniques used and why these techniques were chosen. | Please see section Design and Test a Model Architecture, and sub-sections 1. Describe how you preprocessed the image data. What techniques were chosen and why did you choose these techniques? Consider including images showing the output of each preprocessing technique. Pre-processing refers to techniques such as converting to grayscale, normalization, etc. (OPTIONAL: As described in the “Stand Out Suggestions” part of the rubric, if you generated additional data for training, describe why you decided to generate additional data, how you generated the data, and provide example images of the additional data. Then describe the characteristics of the augmented training set like number of images in the set, number of images for each class, etc.), 1.1. Normalization, 1.2. Conversion to YUV space | |
| Model Architecture | The submission provides details of the characteristics and qualities of the architecture, including the type of model used, the number of layers, and the size of each layer. Visualizations emphasizing particular qualities of the architecture are encouraged. | Please see section Design and Test a Model Architecture, and sub-sections 2. Describe what your final model architecture looks like including model type, layers, layer sizes, connectivity, etc.) Consider including a diagram and/or table describing the final model, Model Pipeline, Computational Graph from TensorBoard. | |
| Model Training | The submission describes how the model was trained by discussing what optimizer was used, batch size, number of epochs and values for hyperparameters. | Please see section Design and Test a Model Architecture, and sub-sections 3. Describe how you trained your model. The discussion can include the type of optimizer, the batch size, number of epochs and any hyperparameters such as learning rate, 4. Describe the approach taken for finding a solution and getting the validation set accuracy to be at least 0.93. Include in the discussion the results on the training, validation and test sets and where in the code these were calculated. Your approach may have been an iterative process, in which case, outline the steps you took to get to the final solution and why you chose those steps. Perhaps your solution involved an already well known implementation or architecture. In this case, discuss why you think the architecture is suitable for the current problem | |
| Solution Approach | The submission describes the approach to finding a solution. Accuracy on the validation set is 0.93 or greater. | Please see section Design and Test a Model Architecture, and sub-sections 3. Describe how you trained your model. The discussion can include the type of optimizer, the batch size, number of epochs and any hyperparameters such as learning rate, 4. Describe the approach taken for finding a solution and getting the validation set accuracy to be at least 0.93. Include in the discussion the results on the training, validation and test sets and where in the code these were calculated. Your approach may have been an iterative process, in which case, outline the steps you took to get to the final solution and why you chose those steps. Perhaps your solution involved an already well known implementation or architecture. In this case, discuss why you think the architecture is suitable for the current problem | |
| Acquiring New Images | The submission includes five new German Traffic signs found on the web, and the images are visualized. Discussion is made as to particular qualities of the images or traffic signs in the images that are of interest, such as whether they would be difficult for the model to classify | Please see section Test a Model on New Images, and sub-sections 1. Choose at least five German traffic signs found on the web and provide them in the report. For each image, discuss what quality or qualities might be difficult to classify. | |
| Performance on New Images | The submission documents the performance of the model when tested on the captured images. The performance on the new images is compared to the accuracy results of the test set. | Please see section Test a Model on New Images, and sub-sections 2. Discuss the model’s predictions on these new traffic signs and compare the results to predicting on the test set. At a minimum, discuss what the predictions were, the accuracy on these new predictions, and compare the accuracy to the accuracy on the test set (OPTIONAL: Discuss the results in more detail as described in the “Stand Out Suggestions” part of the rubric). | |
| Model Certainty - Softmax Probabilities | The top five softmax probabilities of the predictions on the captured images are outputted. The submission discusses how certain or uncertain the model is of its predictions. | Please see section Test a Model on New Images, and sub-sections 3. Describe how certain the model is when predicting on each of the five new images by looking at the softmax probabilities for each prediction. Provide the top 5 softmax probabilities for each image along with each probability. (OPTIONAL: as described in the “Stand Out Suggestions” part of the rubric, visualizations can also be provided such as bar charts) |
I used numpy to calculate summary statistics of the traffic signs data set:
Here is an exploratory visualization of the data set.
We can see clearly there are classes like 2 and 1 with 5.7% of training set vs. classes like 37 and 0 with 0.51% of training set.
I used the following preprocessing pipeline:
Specifically, I used the recommended tranformation pixel <- (pixel - 128)/ 128
After normalization, as shown in P. Sermanet, Y. LeCun, Traffic Sign Recognition with Multi-Scale Convolutional Networks Proceedings of International Joint Conference on Neural Networks (IJCNN’11), 2011, all 32x32 images are converted to YUV space.
YUV encodes a color image taking human perception into account, allowing reduced bandwidth for chrominance components, thereby typically enabling transmission errors or compression artifacts to be more efficiently masked by the human perception than using a “direct” RGB-representation.
Specifically, I used skimage.color.rgb2yuv function that uses this approach for conversion from RGB.
I started with the LeNet-5 solution from the lecture and here are the main nimprovments:
| Layer | Description |
|---|---|
| Input | 32x32x3 YUV image |
| Convolution 5x5 | 1x1 stride, valid padding, outputs 28x28x6 |
| RELU | |
| Local Response Normalization | |
| Max pooling | kernel 2x2, 1x1 stride, outputs 27x27x6 |
| Convolution 5x5 | 1x1 stride, valid padding, outputs 23x23x16 |
| RELU | |
| Local Response Normalization | |
| Max pooling | kernel 2x2, 1x1 stride, outputs 22x22x16 |
| Multi-Scale Features | the output of the first stage is branched out and fed to the classifier, in addition to the output of the second stage, output 1x12118 |
| Fully connected | 12118x800 |
| RELU | |
| DROPOUT | only for training, keep probabily = 0.5 |
| Fully connected | 800x84 |
| RELU | |
| DROPOUT | only for training, keep probabily = 0.5 |
| Fully connected | 84x43, output 43 logits |
| Softmax | output 43 predicted probabilities |
To train the model, I used an optimizer that implements the Adam algorithm with learning rare set to 0.001, 30 epochs and batch size set to 128. I found out that:
My final model results were:
I was insipred by P. Sermanet, Y. LeCun, Traffic Sign Recognition with Multi-Scale Convolutional Networks Proceedings of International Joint Conference on Neural Networks (IJCNN’11), 2011 although I did not implement the same architecture. Specifically, I used only the first two convolutional layers. Also, after my experiments I decided to use
The main improvements came from
The use of dropout allows to avoid overfitting problems as I discovered that even with an higher number of epochs test accuracy don’t change (using the rule of 30); hence, I used 30 epochs although I could use 20 eopochs having same results.
I am confident my architecture can be extended to achieve >99% accuracy using more convolutional layers as shown in P. Sermanet, Y. LeCun, Traffic Sign Recognition with Multi-Scale Convolutional Networks Proceedings of International Joint Conference on Neural Networks (IJCNN’11), 2011
00 - 01 -
02 -
03 - 04 -
05 -
06 - 07 -
08 -
09 - 10 -
11 -
12 - 13 -
14 -
15 - 16 -
17 -
18 - 19 -
20 -
21 - 22 -
23 -
24 - 25 -
26 -
27 - 28 -
29 -
30 - 31 -
32 -
33 - 34 -
35 -
36 - 37 -
The model was able to achieve Accuracy of 80.0%, i.e. 28 corrected predictions out of 35 cases (3 images did not belong to any of 43 known classes and they have been added only for study the classifier behaviour with unknown signs).
Here are the results of the prediction with related comments:
The code for making predictions on my final model is located in the cell N. 22 of the Ipython notebook.
Here below you can find the top 5 softmax probabilities for each image along with each probability and visualizations are provided such as bar charts
The feature map activations clearly show the outline of the traffic signs, i.e. the CNN finds useful information. Here below you can find the visual output of trained network’s feature maps for a sample of 10 new images imported from the web.